package com.blood.modules.system.controller;

import com.blood.core.resp.GlobalResultStatus;
import com.blood.core.resp.ResponseResult;
import com.blood.modules.system.dto.req.SysRoleAuthorityReq;
import com.blood.modules.system.dto.resp.SysRoleAuthorityListResp;
import com.blood.modules.system.service.ISysRoleAuthorityService;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 角色权限Controller
 *
 * @author daoren
 * @date 2022-12-20 11:45:07
 */
@Api(value = "角色权限", tags = "角色权限")
@ApiSort(999)
@RestController
@RequestMapping("/sys/authority")
public class SysRoleAuthorityController {

    /**
     * 角色权限服务.
     */
    @Autowired
    private ISysRoleAuthorityService sysRoleAuthorityService;


    /**
     * 获取.
     *
     * @return 列表信息
     */
    @ApiOperation(value = "获取角色权限列表信息")
    @PostMapping(value = "/getListInfo")
    public ResponseResult<List<SysRoleAuthorityListResp>> getListInfo() {
        return sysRoleAuthorityService.queryList();
    }

    /**
     * 修改.
     *
     * @param req 修改参数
     * @return 修改结果
     */
    @ApiOperation(value = "启用/禁用")
    @PostMapping(value = "/update")
    public ResponseResult<Void> update(@RequestBody @Validated SysRoleAuthorityReq req) {
        sysRoleAuthorityService.updateInfo(req);
        return GlobalResultStatus.SUCCESS.toResult().responseEmptyBody();
    }
}
